package reflect;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;

public class MethodDemo01 {
    public static void main(String[] args) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
        ArrayList<String> list = new ArrayList<>();
        list.add("100");
        list.add("200");

        Class<?> cls = list.getClass();
        Method method =  cls.getDeclaredMethod("add", Object.class);
        method.invoke(list,300);

        Method method2 =  cls.getDeclaredMethod("add",int.class, Object.class);
        method2.invoke(list,1,300);

        System.out.println(list);

    }

}
